// 新闻API接口
import request from '@/sheep/request';

const NewsApi = {
  // 获取新闻分页列表
  getNewsPage: (params) => {
    return request({
      url: '/system/news/page',
      method: 'GET',
      params,
    });
  },

  // 获取新闻详情
  getNewsDetail: (params) => {
    return request({
      url: '/system/news/get',
      method: 'GET',
      params,
    });
  },

  // 增加阅读量
  incrementReadCount: (params) => {
    return request({
      url: '/system/news/add-browse-count',
      method: 'PUT',
      params,
    });
  },

  // 点赞/取消点赞文章
  likeArticle: (data) => {
    return request({
      url: '/news/like',
      method: 'POST',
      data,
    });
  },

  // 收藏/取消收藏文章
  collectArticle: (data) => {
    return request({
      url: '/news/collect',
      method: 'POST',
      data,
    });
  },

  // 获取用户收藏的文章列表
  getCollectedNews: (params) => {
    return request({
      url: '/news/collected',
      method: 'GET',
      params,
    });
  },

  // 搜索新闻
  searchNews: (params) => {
    return request({
      url: '/news/search',
      method: 'GET',
      params,
    });
  },

  // 获取热门新闻
  getHotNews: (params) => {
    return request({
      url: '/news/hot',
      method: 'GET',
      params,
    });
  },

  // 获取推荐新闻
  getRecommendNews: (params) => {
    return request({
      url: '/news/recommend',
      method: 'GET',
      params,
    });
  },
};

export default NewsApi;

